package com.xxxx;

import org.apache.flink.configuration.Configuration;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.functions.ProcessFunction;
import org.apache.flink.util.Collector;

/**
 * 批量数据处理
 */
public class Hello14FlinkProcess {
    public static void main(String[] args) throws Exception {
        //创建环境
        StreamExecutionEnvironment environment = StreamExecutionEnvironment.createLocalEnvironmentWithWebUI(new Configuration());
        //获取数据源
        DataStreamSource<String> source = environment.socketTextStream("localhost", 18880);
        //对流进行处理
        source.process(new ProcessFunction<String, String>() {

            @Override
            public void onTimer(long timestamp, OnTimerContext ctx, Collector<String> out) throws Exception {
                super.onTimer(timestamp, ctx, out);
            }

            @Override
            public void open(Configuration parameters) throws Exception {
                super.open(parameters);
            }

            @Override
            public void close() throws Exception {
                super.close();
            }

            @Override
            public void processElement(String s, Context context, Collector<String> collector) throws Exception {

            }
        }).print();


        //执行流
        environment.execute("Hello08FlinkOperatorConnect" + System.currentTimeMillis());

    }
}
